package sf.database.template;

import org.smallframework.spring.path.SpringClassPathScanning;
import sf.database.OrmConfig;
import sf.database.template.enjoy.EnjoyHandler;
import sf.database.template.freemarker.FreemarkerHandler;
import sf.spring.core.io.Resource;

import java.util.Arrays;
import java.util.Set;

public class TemplateRender {
    public static TemplateHandler getTemplateHandler() {
        //默认使用enjoy
        switch (OrmConfig.getInstance().getSqlTemplateType()) {
            case enjoy:
                return EnjoyHandler.getInstance();
            case freemarker:
                return FreemarkerHandler.getInstance();
            default:
                return EnjoyHandler.getInstance();
        }
    }

    public static String[] path = new String[]{"classpath*:sql/**/*.sql"};

    public static Set<Resource> getAllSqlTemplate() {
        return SpringClassPathScanning.getResources(null, Arrays.asList(path));
    }
}
